package com.server.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MessageParserUtil {
    public static String extractCameraId(String message) {
        Pattern pattern = Pattern.compile("deviceId:\\s*([\\w-]+)");
        Matcher matcher = pattern.matcher(message);
        if (matcher.find()) {
            return matcher.group(1);
        }
        return null;
    }

    public static String extractOperation(String message) {
        Pattern pattern = Pattern.compile("operation:\\s*\\[([\\w]+)]");
        Matcher matcher = pattern.matcher(message);
        if (matcher.find()) {
            return matcher.group(1);
        }
        return null;
    }

    public static String extractProtocol(String message) {
        Pattern pattern = Pattern.compile("protocol:\\s*([\\w]+)");
        Matcher matcher = pattern.matcher(message);
        if (matcher.find()) {
            return matcher.group(1);
        }
        return null;
    }
}
